<template>
    <div class="container">
        <Header :left="true" title="提现"></Header>
        
        <div class="box" style="padding:20px;margin-top:0;" >
            <div>到账账号</div>
            <div style="margin-top:10px;" >{{info.trueName}} {{info.alipayAccount}}</div>
        </div>

        <div class="box" style="padding:20px;">
            <div>提现金额（最多可提现¥ {{fMoney(null,null,info.money)}}）</div>
            <div style="position:relative;margin-top:15px;">
                <el-button  class="tip-btn" @click="form.money = fMoney(null,null,info.money)" type="text">全部提现</el-button>
                <el-input size="medium" v-model="form.money" style="width:100%"  :placeholder="'请输入提现金额，最多可提现 ¥ ' + fMoney(null,null,info.money)" />
            </div>

            <el-button style="width:100%;margin-top:40px;" @click="confirmEvent" :loading="form.loading" type="primary">确认</el-button>
        </div>

    </div>
</template>
<script>
import Header from '../../common/Header.vue';
export default {
    components:{Header},
    data:function(){
        return {
            info:{
                trueName:'',
                alipayAccount:'',
                money:0,
                transferType:''
            },
            form:{
                money:'',
                loading:false
            }
        };
    },
    created:function(){
        var txt = localStorage.getItem('withdrawdepositinfo');
        if(txt){
            this.info = JSON.parse(txt);
        }
    },
    methods:{
        confirmEvent(){
            var that = this;
            var body = {amount:that.form.money,transferType:this.info.transferType}
            that.form.loading = true;
            that.$api.post('/channel/channelWithdrawDeposit/save.json',body).then(data =>{
                that.form.loading = false;
                if(data.data.code != '0'){
                    that.$message.error(data.data.msg);
                    return;
                }
                that.$message.success('提交成功');
                localStorage.removeItem('withdrawdepositinfo');
                that.$router.go(-1);
            }).catch(()=>{
                that.form.loading = false;
            });
        }
    }
}
</script>
<style scoped>
    .container{
        width: 100%;min-height: 100%;
        background: #F2F6FC;
        padding: 20px;
        color:#303133;
    }
    .box{
        width: 100%;
        background: #fff;
        border-radius: 10px;
        position: relative;
        padding: 0 10px;
        margin-top:20px;
    }
    .tip-btn{
        position: absolute;
        top:0;bottom: 0;
        margin: auto;
        right: 10px;
        z-index: 1;
    }
    
</style>
